﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace floc
{
    class Program
    {
        static string fileName;
        static string outputFileName;
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintHelp();   
            }
            else
            {           
                if (args.Length == 1)
                {
                    PrintHelp();
                }
                else if (args.Length == 2)
                {
                    fileName = args[0];
                    outputFileName = args[1];
                    var xc = File.ReadAllLines(fileName).Where(arg => !string.IsNullOrWhiteSpace(arg));
                    Compiler c = new Compiler(xc.ToArray());
                    if (!c.Error)
                    {
                        File.WriteAllText(outputFileName, c.IL);
                    }
                    else
                    {
                        Console.WriteLine("An error occured while compiling.");
                        return;
                    }
                }
                else
                {
                    PrintHelp();
                }
            }
        }

        static void PrintHelp()
        {
            Console.WriteLine("Flow compiler version 0.1a - Help");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("Usage: floc.exe <input file name> <output file name>.vasm [<parameters>]");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("Currently, there is no WORKING parameters :/");
        }

    }
}
